/***********************************************************************
 * Module:  Package.java
 * Author:  Stefan
 * Purpose: Defines the Class Package
 ***********************************************************************/

package org.dslintegration.merge.km3.core;

import java.util.ArrayList;
import java.util.List;

public class Package extends ModelElement {
	protected List<ModelElement> contents = new ArrayList<ModelElement>();

	public Package() {

	};

	public Package(String name) {
		this.name = name;
	}

	public List<ModelElement> getContents() {
		return contents;
	}

	public void setContents(List<ModelElement> contents) {
		this.contents = contents;
	}

	public void addContent(ModelElement element) {
		this.contents.add(element);
	}

	// For data types
	public List<DataType> getDataTypes() {
		List<DataType> dataTypes = new ArrayList<DataType>();
		for (ModelElement el : contents) {
			if (el instanceof DataType) {
				dataTypes.add((DataType) el);
			}
		}
		return dataTypes;
	}

	// For data types
	public List<Class> getClasses() {
		List<Class> dataTypes = new ArrayList<Class>();
		for (ModelElement el : contents) {
			if (el instanceof Class) {
				dataTypes.add((Class) el);
			}
		}
		return dataTypes;
	}

	public List<Enumeration> getEnumerations() {
		List<Enumeration> enumerations = new ArrayList<Enumeration>();
		for (ModelElement el : contents) {
			if (el instanceof Enumeration) {
				enumerations.add((Enumeration) el);
			}
		}
		return enumerations;
	}

	@Override
	public String toString() {
		return "\n\tPackage [location=" + location + ", name=" + name + ",contents=" + contents + "]";
	}

	@Override
	public String getQName() {
		return this.getName();
	}

}
